package com.smart.community.region.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * 区域可视化DTO
 * 
 * @author Wu.Liang
 * @since 2024-12-21
 */
@Data
@Schema(description = "区域可视化DTO")
public class RegionVisualizationDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "区域ID")
    private Long regionId;

    @Schema(description = "区域名称")
    private String regionName;

    @Schema(description = "统计开始日期")
    private LocalDate startDate;

    @Schema(description = "统计结束日期")
    private LocalDate endDate;

    @Schema(description = "统计类型：1-基础统计，2-趋势分析，3-分布统计")
    private Integer statType;

    @Schema(description = "基础统计数据")
    private BasicStats basicStats;

    @Schema(description = "趋势分析数据")
    private List<TrendData> trendData;

    @Schema(description = "分布统计数据")
    private Map<String, Object> distributionStats;

    @Schema(description = "图表配置")
    private ChartConfig chartConfig;

    /**
     * 基础统计数据
     */
    @Data
    @Schema(description = "基础统计数据")
    public static class BasicStats {
        @Schema(description = "社区数量")
        private Integer communityCount;

        @Schema(description = "楼栋数量")
        private Integer buildingCount;

        @Schema(description = "房户数量")
        private Integer householdCount;

        @Schema(description = "居民数量")
        private Integer residentCount;

        @Schema(description = "总面积（平方米）")
        private BigDecimal areaTotal;

        @Schema(description = "入住率（%）")
        private BigDecimal occupancyRate;

        @Schema(description = "户均面积（平方米）")
        private BigDecimal averageAreaPerHousehold;

        @Schema(description = "人均面积（平方米）")
        private BigDecimal averageAreaPerPerson;
    }

    /**
     * 趋势分析数据
     */
    @Data
    @Schema(description = "趋势分析数据")
    public static class TrendData {
        @Schema(description = "日期")
        private LocalDate date;

        @Schema(description = "房户数量")
        private Integer householdCount;

        @Schema(description = "居民数量")
        private Integer residentCount;

        @Schema(description = "入住率（%）")
        private BigDecimal occupancyRate;

        @Schema(description = "新增房户数")
        private Integer newHouseholdCount;

        @Schema(description = "新增居民数")
        private Integer newResidentCount;
    }

    /**
     * 图表配置
     */
    @Data
    @Schema(description = "图表配置")
    public static class ChartConfig {
        @Schema(description = "图表类型：line-折线图，bar-柱状图，pie-饼图")
        private String chartType;

        @Schema(description = "图表标题")
        private String title;

        @Schema(description = "X轴标签")
        private String xAxisLabel;

        @Schema(description = "Y轴标签")
        private String yAxisLabel;

        @Schema(description = "是否显示图例")
        private Boolean showLegend;

        @Schema(description = "图表高度")
        private Integer height;

        @Schema(description = "图表宽度")
        private Integer width;
    }

    /**
     * 地图标记数据
     */
    @Data
    @Schema(description = "地图标记数据")
    public static class MapMarker {
        @Schema(description = "标记ID")
        private Long id;

        @Schema(description = "标记名称")
        private String name;

        @Schema(description = "标记类型")
        private String type;

        @Schema(description = "纬度")
        private BigDecimal latitude;

        @Schema(description = "经度")
        private BigDecimal longitude;

        @Schema(description = "标记图标")
        private String icon;

        @Schema(description = "标记信息")
        private String info;
    }

    /**
     * 区域边界数据
     */
    @Data
    @Schema(description = "区域边界数据")
    public static class RegionBoundary {
        @Schema(description = "区域ID")
        private Long regionId;

        @Schema(description = "区域名称")
        private String regionName;

        @Schema(description = "边界坐标点")
        private List<Coordinate> coordinates;

        @Schema(description = "边界样式")
        private String style;
    }

    /**
     * 坐标点
     */
    @Data
    @Schema(description = "坐标点")
    public static class Coordinate {
        @Schema(description = "纬度")
        private BigDecimal latitude;

        @Schema(description = "经度")
        private BigDecimal longitude;
    }

    /**
     * 面积热力图数据
     */
    @Data
    @Schema(description = "面积热力图数据")
    public static class AreaHeatmap {
        @Schema(description = "区域ID")
        private Long regionId;

        @Schema(description = "区域名称")
        private String regionName;

        @Schema(description = "面积值")
        private BigDecimal areaValue;

        @Schema(description = "热力值")
        private BigDecimal heatValue;

        @Schema(description = "颜色")
        private String color;
    }

    /**
     * 人口统计数据
     */
    @Data
    @Schema(description = "人口统计数据")
    public static class PopulationStats {
        @Schema(description = "区域ID")
        private Long regionId;

        @Schema(description = "区域名称")
        private String regionName;

        @Schema(description = "总人口")
        private Integer totalPopulation;

        @Schema(description = "男性人口")
        private Integer malePopulation;

        @Schema(description = "女性人口")
        private Integer femalePopulation;

        @Schema(description = "人口密度")
        private BigDecimal populationDensity;
    }

    /**
     * 社区分布数据
     */
    @Data
    @Schema(description = "社区分布数据")
    public static class CommunityDistribution {
        @Schema(description = "区域ID")
        private Long regionId;

        @Schema(description = "区域名称")
        private String regionName;

        @Schema(description = "社区数量")
        private Integer communityCount;

        @Schema(description = "楼栋数量")
        private Integer buildingCount;

        @Schema(description = "房户数量")
        private Integer householdCount;

        @Schema(description = "入住率")
        private BigDecimal occupancyRate;
    }

    /**
     * 楼栋房户趋势数据
     */
    @Data
    @Schema(description = "楼栋房户趋势数据")
    public static class BuildingHouseholdTrend {
        @Schema(description = "日期")
        private String date;

        @Schema(description = "楼栋数量")
        private Integer buildingCount;

        @Schema(description = "房户数量")
        private Integer householdCount;

        @Schema(description = "居民数量")
        private Integer residentCount;

        @Schema(description = "入住率")
        private BigDecimal occupancyRate;
    }

    /**
     * 地理查询结果
     */
    @Data
    @Schema(description = "地理查询结果")
    public static class GeoSearchResult {
        @Schema(description = "查询地址")
        private String address;

        @Schema(description = "纬度")
        private BigDecimal latitude;

        @Schema(description = "经度")
        private BigDecimal longitude;

        @Schema(description = "区域信息")
        private String regionInfo;

        @Schema(description = "距离")
        private BigDecimal distance;
    }
} 